ENT.Type = "anim"
ENT.Base = "base_anim"
ENT.PrintName = "Money Printer"
ENT.Author = "Render Case and philxyz"
ENT.Spawnable = true
ENT.AdminSpawnable = true
ENT.Category            = "base_combat"

function ENT:SpawnFunction( ply, tr )

    if ( !tr.Hit ) then return end

    local SpawnPos = tr.HitPos + tr.HitNormal * 16

    local ent = ents.Create( ClassName or "mccake" )
		ent:SetDTEntity(0,ply)
        ent:SetPos(SpawnPos)
        ent:Spawn()
        ent:Activate()
    return ent

end

function ENT:Initialize()

    if ( SERVER ) then

        self:SetModel("models/props_c17/consolebox01a.mdl")
        self:PhysicsInit(SOLID_VPHYSICS)
        self:SetMoveType( MOVETYPE_VPHYSICS )
        self:SetSolid(SOLID_VPHYSICS)
		timer.Simple(27, PrintMore, self)
    end

end

function ENT:Think()

    local phys = self.Entity:GetPhysicsObject()
    if (phys:IsValid()) then
		phys:SetMass(10)
        phys:Wake()
    end
    
end

function ENT:OnTakeDamage( dmginfo )

    self:TakePhysicsDamage( dmginfo )

end


function PrintMore(self)
local ply = self:GetDTEntity(0)
player_cash[ply:UserID()] = player_cash[ply:UserID()] + 10
umsg.Start("set_cash", ply);
umsg.Long(player_cash[ply:UserID()]);
umsg.End();
umsg.Start("chat_pay",ply);
umsg.String("Money Printer payed you $10")
umsg.End();
timer.Simple(60, PrintMore, self)
end 


function ENT:Draw()
	self.Entity:DrawModel()
	
		local Pos = self.Entity:GetPos()
	local Ang = self.Entity:GetAngles()
	
	local owner = self.Entity:GetDTEntity(0)
	owner = (ValidEntity(owner) and owner:Nick()) or "unknown"
	
	surface.SetFont("HUDNumber5")
	local TextWidth = surface.GetTextSize("Money printer")
	local TextWidth2 = surface.GetTextSize(owner)
	
	Ang:RotateAroundAxis(Ang:Up(), 90)
	
	cam.Start3D2D(Pos + Ang:Up() * 11.5, Ang, 0.11)
		draw.WordBox(2, -TextWidth*0.5, -30, "Money printer", "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255))
		draw.WordBox(2, -TextWidth2*0.5, 18, owner, "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255))
	cam.End3D2D()
end
